﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
    <!-- Google Chrome Frame也可以让IE用上Chrome的引擎: -->
    <meta name="renderer" content="webkit">
    <!--国产浏览器高速模式-->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="author" content="1024招聘" />
    <!-- 作者 -->
    <meta name="revised" content="1024招聘.v3, 2019/05/01" />
    <!-- 定义页面的最新版本 -->
    <meta name="description" content="网站简介" />
    <!-- 网站简介 -->
    <meta name="keywords" content="搜索关键字，以半角英文逗号隔开" />
    <title>1024招聘</title>

    <!-- 公共样式 开始 -->
    <link rel="stylesheet" type="text/css" href="../../css/base.css">
    <link rel="stylesheet" type="text/css" href="../../fonts/iconfont.css">
    <script type="text/javascript" src="../../framework/jquery-1.11.3.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../../layui/css/layui.css">
    <script type="text/javascript" src="../../layui/layui.js"></script>
    <script src="../../framework/cframe.js"></script><!-- 仅供所有子页面使用 -->
    <!-- 公共样式 结束 -->

</head>

<body>
    <div class="cBody">
        <div class="console">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <div class="layui-input-inline">
                        <input type="text" id="Managername" placeholder="输入分管名称" autocomplete="off" class="layui-input">
                    </div>
                    <button class="layui-btn but_Managername" id="but_Managername" lay-submit lay-filter="submitBut">检索</button>
                    <div id="Industry_add" class="btn btn-warning" title="添加行业信息" style="background-color: #f44336;border-radius:2px 4px 8px 12px;cursor: pointer;border: none;color: white;padding: 9px 18px;text-align: center;text-decoration: none;display: inline-block;
font-size: 16px;"><i class="fa fa-plus"></i> 添加职位</div>
                </div>
            </form>

            <script>
                layui.use('form', function () {
                    var form = layui.form;

                    //监听提交
                    form.on('submit(submitBut)', function (data) {
                        layer.msg(JSON.stringify(data.field));
                        return false;
                    });
                });</script>
        </div>

        <table id="test" class="table table-striped table-bordered table-hover layui-hide" lay-filter="test">
        </table>
        <div class="layui-btn" id="gotuo" lay-filter="submitBut">返回</div>
        <!-- layUI 分页模块 -->
        <div class="h_55"></div>
        <div id="pages"></div>
        @*<script>layui.use(['laypage', 'layer'], function() {
                var laypage = layui.laypage,
                    layer = layui.layer;

                //总页数大于页码总数
                laypage.render({
                    elem: 'pages'
                    ,count: 100
                    ,layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                    ,jump: function(obj){
                      console.log(obj)
                    }
                });
            });</script>*@
    </div>
</body>

</html>
<script type="text/html" id="staor">
    <input type="checkbox" name="yyy" lay-skin="switch" lay-filter="switchTest" value="{{d.ClassId}}" lay-text="启用|禁用" {{d.Status?'checked':''}} />
</script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-xs" id="css" lay-event="secondlevel">下一级</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/javascript">
    $("#gotuo").click(function () {
        var table = layui.table;
        var Managerid = 0;
        $("#Managername").val("");
        table.reload('test', {
            where:{
                   Managerid : Managerid
                  }
            });
    });
    layui.use('table', function () {
        var form = layui.form,
            table = layui.table;

        table.render({
            elem: '#test'
            , url: '/Type/QueryManagerList'
            ,page: true
            , cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            , cols: [[
                { field: 'ClassId', width: 80, title: 'ID', sort: true }
                , { field: 'ClassName', width: 200, title: '分类名称' }
                , { field: 'Status', width: 120, title: '状态', toolbar: '#staor' }
                , { field: 'Remark', width: 110, title: '描述' }
                , { field: 'LEVEL', width: 110, title: '级别' }
                , { field: 'ParentId', width: 110, title: '父级Id' }
                , { field: 'CreateTime', width: 180, title: '创建时间', templet: "<div>{{Format(d.CreateTime,'yyyy-MM-dd hh-mm-ss')}}</div>" }
                , { field: 'Initial', width: 100, title: '首字母' }
                , { title: '操作', fixed: 'right', width: 200, align: 'center', toolbar: '#barDemo' }
            ]]
        });

         //添加职位信息
        $("#Industry_add").click(function () {
            location.href = "/Type/TypeAddManager";
        });

            //条件查询
        $(".but_Managername").click(function () {
            var table = layui.table;
            var ClassName = $("#Managername").val();
        table.reload('test', {
            where:{
                   ClassName : ClassName
                  }
            });
    });

        table.on('tool(test)', function (obj) {
            //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data //获得当前行数据
                , layEvent = obj.event; //获得 lay-event 对应的值
            if (layEvent === 'secondlevel') {
                    var table = layui.table;
                var Managerid = data.ClassId;
                if (data.LEVEL == 2) {
                    location.href = "/Type/TypepostName?Bugeikang="+Managerid;
                } else {
                    table.reload('test', {
                        where:{
                            Managerid : Managerid
                        }
                    });
                }
            } else if (layEvent === 'del') {
                layer.confirm('真的删除行么', function (index) {
                    del(data.ClassId, data.ParentId);
                    obj.del(); //删除对应行（tr）的DOM结构
                    layer.close(index);
                    //向服务端发送删除指令
                });
            } else if (layEvent === 'edit') {
                location.href = "/Type/TypeAddManager?Nolook=" + data.ClassId;
            }
        });

                //删除
        function del(id,pid) {
            var data = {};
            data.ClassId = id;
            data.ParentId = pid;
            $.ajax({
                type: "post",
                url: "/Type/DeleteManager",
                data: data,
                success: function (json) {
                    location.reload();
                    if (json.Success) {
                        layer.alert('删除成功！', {
                            title: '提示框',
                            icon: 1,
                        });
                    } else {
                        layer.alert('删除失败！', {
                            title: '提示框',
                            icon: 0,
                        });
                        layer.close(MenuSection);
                    }
                }
            });
        }


        //修改状态
                layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form
            //监听指定开关
            form.on('switch(switchTest)', function (obj) {
                var date = {};
                date.ClassId = this.value;
                date.Status =obj.elem.checked;
                $.ajax({
                    type: "post",
                    url: "/Type/UpdateManagerStar",
                    data: date,
                    success: function (json) {
                        if (json) {
                            layer.alert('已修改！', {
                                title: '提示框',
                                icon: 1,
                            });
                        } else {
                            layer.alert('修改失败！', {
                                title: '提示框',
                                icon: 1,
                            });
                            layer.close(MenuSection);
                        }
                    }
                });
            });
        });


    });
     function Format(datetime, fmt) {
    var newtime = datetime.replace(/\/Date\((\d+)\)\//gi, "$1");
    if (parseInt(newtime) == newtime) {
        if (newtime.length == 10) {
            newtime = parseInt(newtime) * 1000;
        } else if (newtime.length == 13) {
            newtime = parseInt(newtime);
        }
    }
    newtime = new Date(newtime);
    var o = {
        "M+": newtime.getMonth() + 1,                 //月份
        "d+": newtime.getDate(),                    //日
        "h+": newtime.getHours(),                   //小时
        "m+": newtime.getMinutes(),                 //分
        "s+": newtime.getSeconds(),                 //秒
        "q+": Math.floor((newtime.getMonth() + 3) / 3), //季度
        "S": newtime.getMilliseconds()             //毫秒
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (newtime.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
        };
</script>